انتقال چند داده بین دو TableView
سلام من یک ViewController دارم که با کلیک روی test1 fi به TableView منتقل میشه (TableViewController)
من تو tableview اولی یک ارایه توش تعریف کردم که ۲۰ ردیف ایجاد میکنه مثل این:
var LessonList = ["Lesson 1","Lesson 2","Lesson 3","Lesson 4","Lesson 5","Lesson 6","Lesson 7","Lesson 8","Lesson 9","Lesson 10","Lesson 11","Lesson 12","Lesson 13","Lesson 14","Lesson 15","Lesson 16","Lesson 17","Lesson 18","Lesson 19","Lesson 20"]
و قسمت cell هم به این شکل
overridefunc tableView(tableView: UITableView, cellForRowAtIndexPath indexPath:NSIndexPath) -> UITableViewCell {
let cell: TableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell") as! TableViewCell
cell.cellTitle.text = LessonList[indexPath.row]
return cell
خوب تا اینجاش اوکی هست ۲۰ تا ردیف به ترتیب میاد تو TableView اولیم
حالا تو tableview دومی هم ۲۰ تا ارایه دارم فرض کنید این شکلی
let LessonOneWord: [String] = ["ali","babak","hassan","sara","mahsa","melika","hoda","shery"]
let LessonTwoWord: [String] = ["ketab","daftar","miz","sat","keif","miz","koler","takht"]
.
.
.
حالا میخوام وقتی کاربر روی مثلا "Lesson 1" کلیک کرد تو tableview دومی LessonOneWord نشون داده بشه و اگر روی Lesson 2 کلیک کرد ارایه های LessonTwoWord نشان داده شه
پیشاپیش ممنون از وقتتون
جناب کاشی زاده آموزشاتون حرف نداره واقعا ممنونم
من به این صورت نوشتم ولی مشکل داره LessonOneWord میریزه تو همه
overridefunc tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("CellWord") as! TableViewCellWord
ifLessonList2.contains("Lesson 1") {
cell.cellTitleWord.text = LessonOneWord[indexPath.row]
}
ifLessonList2.contains("Lesson 2") {
cell.cellTitleWord.text = LessonTwoWord[indexPath.row]
}
return cell
}
پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .